home *** CD-ROM | disk | FTP | other *** search
- #include "Picker.h"
-
- pascal void ShowINIT(short iconID , short moveX) ;
-
- pascal void ShowINIT(short iconID , short moveX) {
- asm {
-
- #define True 1
- #define False 0
-
- #define Debug True
-
- #define myH CurApName+32-4 /* a GREAT place to store 4 bytes (it was Darin's idea) */
- #define myCheck myH+2 ; a simple checksum of myH to determine first-timeness
- #define firstX 8 ; X coordinate of first icon to be drawn
- #define bottomEdge 8+32 ; this far from bottom of screen
- #define iconWidth 32 ; size of icon (square normally)
- #define defaultMoveX 40 ; default amount to move icons
- #define checksumConst 0x1021 ; constant used for computing checksum
- #define minColorDepth 4 ; minimum bits/pixel for drawing color icons
-
- #define maskOffset 128 ; offset to mask in ICN#
- #define iconRowBytes 32/8 ; 32/8 bits
-
- #define hasCQDBit 6 ; this bit in ROM85 is cleared if Color QuickDraw is available
-
- #define iconID 6+4 ; positive stackframe objects
- #define moveX 4+4
- #define showINITArgs 4
- #define iconPtrHdl 6+4
- #define initDrawArgs 6
-
- #define saveA5 -4
- #define localA5 -8
- #define thePort localA5-4 ; my own QuickDraw (required!)
- #define gravVars thePort-206+4
- #define destRect gravVars-sizeof(Rect)
- #define myBitMap destRect-sizeof(BitMap)
- #define myPort myBitMap-sizeof(GrafPort)
- #define varsSize myPort
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Displays the ICN# (cicn when in 4 bit mode or higher) specified by iconID and
- ; move the pen horizontally by moveX.
- ; Pass a -1 in moveX to move the standard amount, moveX should be 40 for most ICN#'s
- ;
- ; PROCEDURE ShowINIT(iconID: Integer; moveX: Integer); EXTERNAL
- ;
- ; pascal void ShowINIT(iconID, moveX)
- ; short iconID, moveX;
- ; extern;
- ;
- ;------------------------------------------------------------------------------------------------
- ShowINIT:
-
- ; link a6,#0 ; create stack frame
- movem.l d3-d7/a2-a4,-(sp) ; save standard registers
-
- btst.b #hasCQDBit,ROM85 ; try to get a color icon if CQD exists
- beq.s @ShowINITCQD ; I could use SysEnvirons but I don't want to
- @ShowINIT1Bit
- clr.l -(sp) ; try to get the icon resource
- move.l #'ICN#',-(sp)
- move.w iconID(a6),-(sp)
- _GetResource
- move.l (sp)+,d0
- beq.s @ShowINITError ; can't get it, give up
-
- move.l d0,-(sp) ; leave handle on the stack for ReleaseResource
- move.l d0,a0
- move.l (a0),a0 ; dereference
- move.l a0,-(sp) ; icon pointer
- move.w moveX(a6),-(sp) ; moveX
- bsr @INITDraw1Bit ; draw
- _ReleaseResource ; release the resource
-
- ShowINITExit:
- movem.l (sp)+,d3-d7/a2-a4 ; restore registers
- unlk a6 ; ditch stack frame
- move.l (sp)+,a0 ; get return address
- addq.l #showINITArgs,sp ; ditch incoming arguments
- jmp (a0) ; return to caller
-
- ShowINITError:
- bra.s @ShowINITExit
-
-
- ShowINITCQD:
- move.l MainDevice,a0 ; get handle to main device
- move.l (a0),a0 ; dereference
- move.l OFFSET(GDevice,gdPMap)(a0),a0 ; get its pixmap handle
- move.l (a0),a0 ; dereference it
- cmp.w #minColorDepth,OFFSET(PixMap,pixelSize)(a0) ; is it deep enough for us to draw in color?
- blt.s @ShowINIT1Bit ; no
-
- clr.l -(sp) ; can a color icon be found?
- move.w iconID(a6),-(sp)
- _GetCIcon
- move.l (sp)+,d0
- beq.s @ShowINIT1Bit ; no, so try for regular icon
-
- move.l d0,-(sp) ; leave handle on the stack for DisposCIcon
- move.l d0,-(sp) ; cicn handle
- move.w moveX(a6),-(sp) ; moveX
- bsr @INITDrawCQD ; do the actual drawing
- _DisposCIcon
-
- bra.s @ShowINITExit
-
-
- ShowINITCredits:
- ; dc.w 'ShowINIT by Paul Mercer'
- ; dc.w 'Copyright 1987-1988'
- ; dc.w 'Version of 7/15/88'
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Initializes the world and sets up the drawing rectangle
- ;
- ;------------------------------------------------------------------------------------------------
- INITInit:
-
- move.l CurrentA5,saveA5(a6) ; PM 10/6 save host A5
- lea localA5(a6),a5 ; PM7/21
- move.l a5,CurrentA5
- pea thePort(a6) ; PM 10/6 use a5 reference instead of a6
- _InitGraf ; fixes color bug as per DA@ICOM
- pea myPort(a6)
- _OpenPort
-
- move.w myH,d0 ; get my h var
- rol.w #1,d0 ; compare against checksum
- eor.w #checksumConst,d0
- cmp.w myCheck,d0
- beq.s @ScratchOK ; checks, so go on
- move #firstX,myH ; else initialize as first time
- ScratchOK:
- lea myPort(a6),a0 ; compute the destination rectangle
- move.w OFFSET(GrafPort,portBits)+OFFSET(BitMap,bounds)+OFFSET(Rect,bottom)(a0),d0
- sub.w #bottomEdge,d0
- swap d0
- move.w myH,d0
-
- move.l d0,destRect(a6)
- move.l d0,destRect+OFFSET(Rect,bottom)(a6)
- add.w #iconWidth,destRect+OFFSET(Rect,right)(a6)
- add.w #iconWidth,destRect+OFFSET(Rect,bottom)(a6)
-
- rts
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Cleans up the work done by INITInit and advances the icon drawing position
- ;
- ;------------------------------------------------------------------------------------------------
- INITCleanup:
-
- move.w myH,d0 ; get current position
- move.w moveX(a6),d1 ; get delta x
- bpl.s @NotDefault ; not default (-1)
- move.w #defaultMoveX,d1 ; default
- NotDefault:
- add.w d1,d0 ; increment icon position
- move.w d0,myH ; and save in ‘global’
- rol.w #1,d0 ; recompute checksum
- eor.w #checksumConst,d0
- move.w d0,myCheck ; and save it
- Exit:
- pea myPort(a6)
- _ClosePort
- ; *** (DBA) I think that QuickDraw leaves handles around.
- ; *** (DBA) Too bad we can't get rid of them...
- move.l saveA5(a6),a5 ; PM 10/6 restore host A5
- move.l a5,CurrentA5
- rts
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; display the ICN# pointed to by iconPtr and move the pen horizontally by moveX
- ; pass a -1 in moveX to move the standard amount, moveX should be 40 for most ICN#'s
- ;
- ; PROCEDURE INITDraw1Bit(iconPtr: ICONListPtr; moveX: Integer); EXTERNAL
- ;
- ; pascal void INITDraw1Bit(iconPtr, moveX)
- ; ICONList *iconPtr;
- ; short moveX;
- ; extern;
- ;
- ;------------------------------------------------------------------------------------------------
- INITDraw1Bit:
-
- link a6,#varsSize ; create stack frame
- movem.l d3-d7/a2-a4,-(sp) ; save standard registers
- bsr @INITInit ; initialize for drawing
-
- move.l iconPtrHdl(a6),a3 ; get ICN# pointer
- lea myBitMap(a6),a4 ; point to bitmap structure
- move.l a3,OFFSET(BitMap,baseAddr)(a4) ; fill it out
- add.l #maskOffset,OFFSET(BitMap,baseAddr)(a4) ; skip to mask
- move #iconRowBytes,OFFSET(BitMap,rowBytes)(a4)
- move.l #0,OFFSET(BitMap,bounds)(a4) ; 0,0 topleft
- move.w #iconWidth,OFFSET(BitMap,bounds)+OFFSET(Rect,bottom)(a4) ; 32,32 botright
- move.w #iconWidth,OFFSET(BitMap,bounds)+OFFSET(Rect,right)(a4)
-
- move.l a4,-(sp) ; punch hole with mask
- lea myPort(a6),a2 ; get the desk port
- pea OFFSET(GrafPort,portBits)(a2) ; for its portbits
- pea @srcRect
- pea destRect(a6)
- move #srcBic,-(sp) ; punch a hole
- clr.l -(sp) ; no clip region
- _CopyBits
-
- sub.l #128,OFFSET(BitMap,baseAddr)(a4)
- move.l a4,-(sp) ; now draw (or) icon
- pea OFFSET(GrafPort,portBits)(a2)
- pea @srcRect
- pea destRect(a6)
- move #srcOr,-(sp)
- clr.l -(sp)
- _CopyBits
-
- bsr @INITCleanup ; cleanup, advance icon location
- movem.l (sp)+,d3-d7/a2-a4 ; restore registers
- unlk a6 ; ditch stack frame
- move.l (sp)+,a0 ; get return address
- addq.l #initDrawArgs,sp ; ditch incoming
- jmp (a0) ; back to caller
-
- srcRect: dc.w 0,0,32,32 ; for copybits
-
-
- ;------------------------------------------------------------------------------------------------
- ; same as above except with color icon handle
- ;------------------------------------------------------------------------------------------------
- INITDrawCQD:
-
- link a6,#varsSize ; create stack frame
- movem.l d3-d7/a2-a4,-(sp) ; save standard registers
- bsr @INITInit ; initialize for drawing
-
- pea destRect(a6) ; destination rect
- move.l iconPtrHdl(a6),-(sp) ; cicn handle
- _PlotCIcon ; draw it
-
- bsr @INITCleanup ; cleanup, advance icon location
- movem.l (sp)+,d3-d7/a2-a4 ; restore registers
- unlk a6 ; ditch stack frame
- move.l (sp)+,a0 ; get return address
- addq.l #initDrawArgs,sp ; ditch incoming
- jmp (a0) ; back to caller
-
- }
- }